home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / text / misc / arot.lha / AROT.s < prev   
Text File  |  1995-07-17  |  5KB  |  120 lines

  1. ; ROT translater       Code: Torque              sjoyce@primenet.com
  2.  
  3. mn:        move.l    a0,arg                ; Pointer to command line arguement
  4.         move.l    d0,num                ; Number of characters in arguement
  5.         move.l    $4.w,a6             ; ExecBase
  6.         lea        dos,a1                ; dos library name
  7.         move.l    #0,d0                ; any version
  8.         jsr        -552(a6)                        ; Open Dos Library
  9.         tst.b    d0                    ; Did it open?
  10.         beq        over                ; No? Quit
  11.         move.l    d0,dosbase            ; Save DosBase
  12.         move.l    d0,a6                ; Move DosBase into a useful position
  13.         jsr        -$3c(a6)                        ; Get stdout
  14.         tst.b    d0                    ; Did it work?
  15.         beq        closedos            ; No? Shutdown...
  16.         move.l    d0,output            ; Save stdout
  17. addnul: move.l    arg,a0                ; Get arguement pointer
  18.         move.l    num,d0                ; Get length
  19.         cmpi.b    #1,d0                ; Was there no arguements?
  20.         bne        nul                    ; No? Show syntax message
  21. arg_err:    move.l    output,d1        ; Get stdout in d1
  22.         move.l    #RotInf,d2            ; Pointer to syntax message
  23.         move.l    #RotIsize,d3        ; Length of message
  24.         jsr        -$30(a6)                        ; Write message to current window
  25.         bra        closedos            ; Shutdown...
  26. nul:    add.l    #1,a0                ; Next byte
  27.         dbra    d0,nul                ; Subtract until end of arguement
  28.         sub.l    #2,a0                ; Go back a couple bytes (I.E. LF,NULL)
  29.         move.b    #0,(a0)                         ; Insert NULL terminator
  30. openfile:    move.l    arg,d1            ; The filename to be opened
  31.         move.l    #$000003ed,d2        ; OldFile (Already exists) Flag
  32.         jsr        -$1e(a6)                        ; Attempt file open...
  33.         move.l    d0,fh                ; Get file handle
  34.         tst.b    d0                    ; Did it open?
  35.         bne        readfile            ; Yes? Start the read...
  36. err:    move.l    output,d1            ; File Error occured; stdout to d1
  37.         move.l    #FileErr,d2            ; Pointer to file error message
  38.         move.l    #FEsize,d3            ; Length of message
  39.         jsr        -$30(a6)                        ; Output to current window
  40.         bra        closedos            ; Shutdown...
  41. readfile:    move.l    #Buffer,d2        ; One Byte buffer for read
  42.         move.l    fh,d1                ; File Handle
  43.         move.l    #1,d3                ; Read one byte only
  44.         jsr        -$2a(a6)                        ; Read
  45.         cmpi.b    #-1,d0                ; An error?
  46.         beq        err                    ; Yes? Print File Error message...
  47.         cmpi.b    #0,d0                ; End of File?
  48.         beq        close                ; Yes? Shutdown...
  49. code:    move.b    Buffer,d0            ; Get buffer in d0
  50.         cmpi.b    #123,d0             ; Find out if this byte is -
  51.         bge        print                ; a letter by finding the general -
  52.         cmpi.b    #64,d0                ; range...
  53.         ble        print
  54.         cmpi.b    #91,d0                ; Is it a non-letter in between the
  55.         bge        step2                ; 2 case alphabets?
  56.         move.b    #0,CaseFlag            ; It is Upper case
  57.         bra        crunch
  58. step2:    move.b    #1,CaseFlag            ; It might be a Lower case letter?
  59.         cmpi.b    #96,d0                ; Make sure it is not a non-letter
  60.         ble        print                ; If it is, just print it
  61. crunch: cmpi.b    #1,CaseFlag            ; Is it Lower Case?
  62.         beq        LCase
  63. UCase:    cmpi.b    #78,d0                ; It must be Upper Case, find out if
  64.         bge        sb                    ; the letter is N or greater...
  65.         addi.b    #13,Buffer            ; No, skip to (LETTER+13)
  66.         bra        print                ; Write it to screen...
  67. sb:        subi.b    #13,Buffer            ; Yes, skip to (LETTER-13)
  68.         bra        print                ; Write it to screen...
  69. LCase:    cmpi.b    #110,d0             ; It must be Lower Case, find out if
  70.         bge        sb2                    ; the letter is N or greater...
  71.         addi.b    #13,Buffer            ; No, (LETTER+13)
  72.         bra        print                ; Write it...
  73. sb2:    subi.b    #13,Buffer            ; Yes, (LETTER-13)
  74. print:    move.l    #Buffer,d2            ; the pointer to the current letter
  75.         move.l    output,d1            ; stdout
  76.         move.l    #Bufsize,d3            ; Buffersize (always 1)
  77.         jsr        -$30(a6)                        ; Write the letter...
  78.         move.b    $bfec01,d4            ; Get RAW key
  79.         cmpi.b    #$39,d4             ; Check for CTRL key
  80.         beq        break                ; Did it get pressed? Yes? BREAK...
  81.         bra        readfile            ; Keep going...
  82. break:    move.l    output,d1            ; stdout
  83.         move.l    #brk,d2             ; Break message pointer
  84.         move.l    #brksize,d3            ; Buffer Size
  85.         jsr        -$30(a6)                        ; Write the message
  86. close:    move.b    #10,Buffer            ; Line feed
  87.         move.l    #Buffer,d2            ; Pointer to LF
  88.         move.l    output,d1            ; stdout
  89.         move.l    #Bufsize,d3            ; 1 byte
  90.         jsr        -$30(a6)                        ; Write...
  91. closefile:    move.l    fh,d1            ; Get file handle in d1
  92.         jsr        -$24(a6)                        ; Close file
  93. closedos: move.l    $4.w,a6         ; ExecBase
  94.         move.l    dosbase,a1            ; Get dosbase in a1
  95.         jsr        -$19e(a6)                       ; Close DosBase
  96.         move.l    #0,d0                ; Clear d0 (no errors)..
  97. over:    rts
  98.  
  99.  
  100.  
  101. dos:    dc.b    'dos.library',0
  102. arg:    dc.l    0
  103. num:    dc.l    0
  104. str:    dc.b    0
  105. dosbase:    dc.l    0
  106. output: dc.l    0
  107. RotInf: dc.b    10,'AROT - V1.0, 1994, Public Domain',10
  108.         dc.b    10,'(DE/UNEN)crypts a ROT message and dumps it to the screen.',10
  109.         dc.b    10,'Syntax: AROT <file>',10,10,'<CTRL> Breaks',10,10
  110.         dc.b    'Torque    sjoyce@primenet.com',10,10
  111. RotIsize    EQU    *-RotInf
  112. fh:        dc.l    0
  113. FileErr:    dc.b    10,'FILE ERROR!',10
  114. FEsize    EQU    *-FileErr
  115. Buffer: dc.b    0
  116. Bufsize EQU *-Buffer
  117. CaseFlag:    dc.b    0
  118. brk:    dc.b    10,'*** BREAK ***'
  119. brksize EQU    *-brk
  120.